
package ch.hearc.coursJava.kitBase.map;

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

public class UseMap
	{

	/*------------------------------------------------------------------*\
	|*							Methodes Public							*|
	\*------------------------------------------------------------------*/

	public static void main(String[] args)
		{
		main();
		}

	public static void main()
		{
		useHashMap();
		}

	/*------------------------------------------------------------------*\
	|*							Methodes Private						*|
	\*------------------------------------------------------------------*/

	/**
	 * <pre>
	 * Une hashmap ne contient pas de relation d'ordre
	 * Les elements n'ont pas de position
	 * </pre>
	 */
	private static void useHashMap()
		{
		Map<String, Integer> mapNomAge = new HashMap<String, Integer>();
		fill(mapNomAge);
		afficherViaSet(mapNomAge);
		afficher(mapNomAge);
		afficherKey(mapNomAge);
		afficherValue(mapNomAge);
		}

	private static void afficherValue(Map<String, Integer> mapNomAge)
		{
		System.out.println(mapNomAge.values());
		}

	private static void afficherKey(Map<String, Integer> mapNomAge)
		{
		System.out.println(mapNomAge.keySet());
		}

	private static void afficher(Map<String, Integer> mapNomAge)
		{
		System.out.println(mapNomAge);
		}

	private static void afficherViaSet(Map<String, Integer> mapNomAge)
		{
		Set<Entry<String, Integer>> setEntreeNomAge = mapNomAge.entrySet();
		for(Entry<String, Integer> entrer:setEntreeNomAge)
			{
			//System.out.println(entrer.getKey()+" - "+entrer.getValue());
			System.out.println(entrer);
			}
		}

	private static void fill(Map<String, Integer> mapNomAge)
		{
		mapNomAge.put("Capocasale", 24);
		mapNomAge.put("Droz", 23);
		mapNomAge.put("Amiet", 21);
		}
	}
